Micron Document
Jon's Git Node

Node / forks / nomadnet / commits / d2de625

Commit d2de625e5f36ee0922180bd540b3df83b50fbeb2


Parents : 1d99e0d
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-09-10T14:47:20+02:00

Wrap browser keypress handler to avoid crash on intermittent listbox invalid offset

Changes

1 files changed, 22 insertions(+), 16 deletions(-)


Diff

diff --git a/nomadnet/ui/textui/Browser.py b/nomadnet/ui/textui/Browser.py
index c9c0c22..edfa939 100644
--- a/nomadnet/ui/textui/Browser.py
+++ b/nomadnet/ui/textui/Browser.py
@@ -161,23 +161,29 @@ class PageList(urwid.ListBox):
return unhandled_key
def handle_key(self, size, key):
- if key in ("page up", "page down", "home", "end"):
- focus_widget = self.focus
- if focus_widget is not None and focus_widget.selectable():
- key = focus_widget.keypress((size[0],), key)
- if key is None:
- self.make_cursor_visible(size)
- return None
-
- if key == "page down": self.scroll(size[1] - 1)
- elif key == "page up": self.scroll(1 - size[1])
- elif key == "home": self.set_scrollpos(0)
- elif key == "end": self.set_scrollpos(self.rows_max(size))
- return None
+ try:
+ if key in ("page up", "page down", "home", "end"):
+ focus_widget = self.focus
+ if focus_widget is not None and focus_widget.selectable():
+ key = focus_widget.keypress((size[0],), key)
+ if key is None:
+ self.make_cursor_visible(size)
+ return None
+
+ if key == "page down": self.scroll(size[1] - 1)
+ elif key == "page up": self.scroll(1 - size[1])
+ elif key == "home": self.set_scrollpos(0)
+ elif key == "end": self.set_scrollpos(self.rows_max(size))
+ return None
+
+ unhandled_key = super().keypress(size, key)
+ if key in ("up", "down"): return None
+ return unhandled_key
- unhandled_key = super().keypress(size, key)
- if key in ("up", "down"): return None
- return unhandled_key
+ except Exception as e:
+ RNS.log(f"Error while handling browser keypress: {e}", RNS.LOG_ERROR)
+ RNS.trace_exception(e)
+ return None
def mouse_event(self, size, event, button, col, row, focus):
self._page_size = size

Served by rngit 1.5.4 - Generated in 0.02s